package com.itheima.redbaby.activity;


import com.itheima.redbaby.BaseActivity;
import com.itheima.redbaby.GloableParams;
import com.itheima.redbaby.R;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 订单提交成功的界面
 * @author lzl
 */
public class OrderCommitOkActivity extends BaseActivity implements OnClickListener {
	private TextView orderid_value_text;
	private TextView paymoney_value_text;
	private TextView paytype_value_text;
	private TextView continue_shoping_text;
	private TextView to_order_detail_text;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if(GloableParams.cartitemlist!=null){
		GloableParams.cartitemlist.clear();
		}if(GloableParams.cartMap!=null){
			GloableParams.cartMap.clear();
		}
		setContentView(R.layout.order_submit_ok_activity);
		init();
	}
	private void init() {
		Intent intent = getIntent();
		String ranOrderId = intent.getStringExtra("ranOrderId");//订单id号码
		float shouldPay = intent.getFloatExtra("summary_shouldpay_money", 0);//应付金额
		int payType = intent.getIntExtra("ranOrderId",3);//支付方式
		
		orderid_value_text = (TextView) FId(R.id.orderid_value_text);//订单号
		paymoney_value_text = (TextView) FId(R.id.paymoney_value_text);//应付金额
		paytype_value_text = (TextView) FId(R.id.paytype_value_text);//支付类型
		//TODO 给他们设置订单的数据 
		orderid_value_text.setText(ranOrderId);
		paymoney_value_text.setText(shouldPay+"");
		
		String text="";
		if(payType==1){
			text="到付-现金";
		}else if(payType==2){
			text="到付-poss";
		}else if(payType==3){
			text="支付宝";
		}
		paytype_value_text.setText(text);
		
		continue_shoping_text = (TextView) FId(R.id.continue_shoping_text);//继续购物
		to_order_detail_text = (TextView) FId(R.id.to_order_detail_text);//订单详情
		continue_shoping_text.setOnClickListener(this);
		to_order_detail_text.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.continue_shoping_text://继续购物

			intent=new Intent(OrderCommitOkActivity.this,HomeActivity.class);
			startActivity(intent);
			break;
		case R.id.to_order_detail_text://查看订单详情
			intent=new Intent(OrderCommitOkActivity.this,OrderActivity.class);
			startActivity(intent);
			break;
		}
	}
}
